package com.tzx.fluttermixedapplication.net.api

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.withContext

interface IApiService {
    suspend fun <T> runNetWorkAction(block: suspend CoroutineScope.() -> T): Result<T> {
        return withContext(Dispatchers.IO + SupervisorJob()) {
            return@withContext kotlin.runCatching {
                block.invoke(this@withContext)
            }
        }
    }
}